home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 July
/
Macworld (1999-07).dmg
/
Serious Software
/
OpenWorld demo 2.0
/
Development
/
Utils
/
OpenWorld_utils.c
next >
Wrap
Text File
|
1999-04-21
|
2KB
|
77 lines
/*
OpenWorld_utils.h
Useful routines for OpenWorld (source file)
Version 1.0
Copyright ©1998-99, Marco Bambini, Inc. All rights reserved.
*/
#include "OpenWorld_utils.h"
//*********************************************************************************************************//
// up_strstr
// search fpr the string pat in the string str ignoring case
//
// modified by Marco Bambini
// based on Metrowerks Standard Library Version 4.0 1998 August 10 (Copyright © 1995-1998 Metrowerks, Inc.)
//
// returns NULL if pat is not found
//
// PowerPC only version
//*********************************************************************************************************//
char *up_strstr(const char * str, const char * pat)
{
#ifdef __POWERPC__
unsigned char * s1 = (unsigned char *) str-1;
unsigned char * p1 = (unsigned char *) pat-1;
unsigned long firstc, c1, c2;
if ((pat == NULL) || (!(firstc = toupper(*++p1)))) /* 980807 vss PPC must be pre-increment */
/* 980424 mm if pat is a NULL pointer, we return str */
/* 971017 beb if pat is an empty string we return str */
return((char *) str);
while(c1 = toupper(*++s1))
if (c1 == toupper(firstc))
{
const unsigned char * s2 = s1-1;
const unsigned char * p2 = p1-1;
while ((c1 = toupper(*++s2)) == (c2 = toupper(*++p2)) && c1);
if (!c2)
return((char *) s1);
}
#endif
return(NULL);
}
//*********************************************************************************************************//
// up_strcmp
// compare two strings ignoring case
//
// modified by Marco Bambini
// based on Metrowerks Standard Library Version 4.0 1998 August 10 (Copyright © 1995-1998 Metrowerks, Inc.)
//
// returns 0 if equal
//
// PowerPC only version
//*********************************************************************************************************//
int up_strcmp(const char * str1, const char * str2)
{
#ifdef __POWERPC__
const unsigned char * p1 = (unsigned char *) str1 - 1;
const unsigned char * p2 = (unsigned char *) str2 - 1;
unsigned long c1, c2;
while ((c1 = toupper(*++p1)) == (c2 = toupper(*++p2)))
if (!c1)
return(0);
return(c1 - c2);
#endif
}